Repository navigation
feat(qwp): add owned_by to name the owner of the tables a sender auto-creates - #130
glasstiger wants to merge 8 commits into
Conversation
… auto-creates The owned_by connect-string key, and LineSenderBuilder.ownedBy(), name the user, group or service account that QuestDB Enterprise grants the owner permissions on every table and column the sender auto-creates, as OWNED BY does in SQL. An external (OIDC) user cannot hold those permissions itself, so it must name one of its groups to auto-create anything. - The sender sends the owner as X-QWP-Owned-By, percent-encoded UTF-8, on every upgrade, reconnects and failovers included. WebSocket only: http, tcp and udp connect strings and builders reject it. - The upgrade fails unless the server echoes the owner, so a server that predates the header fails the connection instead of creating tables without the owner. The failure is a non-421 WebSocketUpgradeException, which the connect walk treats as terminal. - A rejected upgrade now carries the plain-text body of the response as its reason, sanitized and length-capped, in WebSocketUpgradeException and in QwpAuthFailedException (getReason()), so a refused owner is told apart from a rejected credential.
The owned_by helpers were inserted between pollDurableAckRequest() and its javadoc, which then documented pollOwnedByRequest() instead. Move the javadoc back, give the new helpers their own, and attach an older javadoc that sat loose above them to setSuppressDurableAckHeader(), the method it describes.
WebSocketClient.upgrade() throws WebSocketUpgradeException with status 101 when the server completes the upgrade without echoing the owned_by the client asked for, but the class javadoc still said the exception means a non-101 status. The javadoc now names that case.
Tests now pin the parts of owned_by and of the upgrade reject reason that nothing checked before: - A reconnect and an orphan drainer's upgrade send X-QWP-Owned-By again, not only the first connect (QwpOwnedByTest, BackgroundDrainerEndToEndTest). - The reject reason stays null when the Content-Length exceeds the bytes received, is malformed or not positive, the body is not text/plain, or it is blank, and it reaches messages only sanitized and capped at 256 characters. TestWebSocketServer can now send reject headers that do not describe the body. - encodeOwnedBy keeps the ends of the unreserved ranges and encodes the characters just outside them, as the server's re-encoded echo must match it byte for byte. The owned_by echo failure now carries STATUS_NONE instead of 101: the server answered 101 and rejected nothing, so Sender.health() reports status 0 for it, as it does for the durable-ack gap and as ConnectionHealth documents. The ownedBy() javadoc no longer says the built-in admin may name any entity: Enterprise refuses an external user as the owner, the admin's choice included.
WebSocketClient's comment on the owned_by echo check said that the connect walk latches a missing echo as terminal. That holds for the initial connect and for an orphan drainer, but a sender that has connected before keeps retrying the error, as QwpOwnedByTest.testHealthReportsUnconfirmedOwnedByWithoutStatus asserts. The comment now says so, and so does the test helper that repeated it. TestWebSocketServer's suppressOwnedByEcho flag becomes isOwnedByEchoSuppressed, set with setOwnedByEchoSuppressed(), as the project names booleans with an is or has prefix.
A connect round that met a 421 role reject on one endpoint demoted a 101 without the owned_by echo from another endpoint to a role mismatch, as it demotes every plain non-421 upgrade error. build() then reported a missing primary, an async sender retried forever while its health said every endpoint was a replica, and the real cause survived only as a suppressed exception. The missing or mismatched echo now throws QwpOwnedByMismatchException, a WebSocketUpgradeException that the round epilogue does not demote: like a missing durable-ack echo, it comes from a writable endpoint that lacks the capability. A sender fails its initial connect with it and an orphan drainer quarantines its slot, as they already did with a single endpoint, and a sender that has connected before keeps retrying it. QwpOwnedByTest covers both mixed rounds: a 101 without the echo, and a 403 refusal, which surfaces with its reason.
Review: questdb-enterprise#1572 + questdb/questdb#8504 (+ #130)Tandem review at level 3 of questdb-enterprise Verdict: approve for #1572, #8504 and #130. There are no Critical or Moderate findings, and the one Minor test-hygiene item has since been fixed. CriticalNone. ModerateNone. Minor (fixed)[OSS]
Fixed in questdb CoverageThe test gate passes, with no coverage gaps that block or need a fix. The two Summary
Intended behaviour change, worth a release note: an external (OIDC) principal that names no owner is now refused ( |
An orphan drainer quarantined its slot on the first connect round in which a writable endpoint answered 101 without the X-QWP-Owned-By echo. Such an endpoint lacks the feature, as one without durable ack lacks that, and a rolling upgrade or a failover back to an upgraded node clears it. Yet the drainer took the missing echo for a rejected upgrade and set the slot's rows aside behind a .failed sentinel that nothing in production clears, where a missing durable-ack echo gets a settle budget of 16 sweeps for exactly this reason. BackgroundDrainer now counts QwpOwnedByMismatchException toward the same capability-gap episode as QwpDurableAckMismatchException, and quarantines the slot only once that budget runs out, with a reason that names owned_by. Mid-drain, CursorWebSocketSendLoop hands the exception back to the drainer as a capability-gap terminal rather than a final one, so the drainer re-enters the budget. The durable-ack listener callbacks keep reporting durable ack only. A sender that has connected before keeps retrying, and the initial connect still fails at once. Tests cover the ride-out, the escalation and the shared budget at the initial connect, the same mid-drain, and the sender's own connect walk against a server that leaves the echo out for two sweeps.
Review: questdb/questdb-enterprise#1572 + questdb/questdb#8504 + #130Tandem review at level 3 of questdb-enterprise Verdict: approve for questdb/questdb-enterprise#1572, questdb/questdb#8504 and #130. There are no Critical or Moderate findings. The one Minor item has since been fixed. CriticalNone. ModerateNone. Minor (fixed)[ENT]
Fixed in questdb-enterprise CoverageThe test gate passes, with no coverage gaps. The enterprise owner suites pass at questdb-enterprise In that run, the OIDC concurrent-create test took the retriable "table is being created" branch. Summary
Intended behaviour changes, worth a release note:
|
A connect round latches its first non-421 upgrade failure, and a 421 from another endpoint demotes a plain one, such as a proxy's 503, to a role mismatch. When that plain failure came before an endpoint that answered 101 without the durable ack or the owned_by echo the sender asked for, the demotion hid the capability gap as well. The initial connect then reported "no endpoint matches target=PRIMARY", a SYNC connect retried it for its whole reconnect budget, and an ASYNC one never failed, while the same endpoints in another order reported the gap. connectWalk now keeps the round's first capability gap apart from the latch and throws it when the 421 demotes the latched error, which it attaches as suppressed. A round without a 421 behaves as before. QwpOwnedByTest and WriteFailoverTest walk a 503, a primary without the echo and a replica, in that order. Fixes #131
[PR Coverage check]😍 pass : 129 / 130 (99.23%) file detail
|
Review: questdb/questdb-enterprise#1572 + questdb/questdb#8504 + #130Tandem review at level 3 of questdb-enterprise Verdict: approve for questdb/questdb-enterprise#1572, questdb/questdb#8504 and #130. There are no Critical, Moderate or Minor findings. CriticalNone. ModerateNone. MinorNone. CoverageThe test gate passes, with no coverage gaps that block or need a fix. Summary
Behaviour changes worth a release note:
|
Companion to questdb/questdb#8504 and questdb/questdb-enterprise#1572; docs in questdb/documentation#652. Matching branch
ia_qwp_owned_by.Problem
QWP ingestion auto-creates the tables and columns a sender writes, and QuestDB Enterprise grants the creator the owner permissions on them. An external user, one authenticated with an OIDC token such as an Entra ID managed identity, cannot hold permissions, so it could not auto-create anything over QWP. SQL solves this with
OWNED BY; QWP had no equivalent.Changes
owned_by=<name>connect-string key (an ingress key inConfigSchema) andLineSenderBuilder.ownedBy(String).ws/wssonly:http,tcpandudpconnect strings and builders reject it. TheQwpQueryClientaccepts it as a no-op, like the other ingress keys.X-QWP-Owned-Byon every upgrade, reconnects, failovers and background drainers included. The value is percent-encoded UTF-8 (RFC 3986 unreserved characters as they are, upper-case hex digits), so names outside ASCII survive.QwpOwnedByMismatchException, a non-421WebSocketUpgradeExceptionthat the connect walk treats as terminal, also when another endpoint of the round answered 421: like a missing durable-ack echo, it comes from a writable endpoint that lacks the capability, so the round reports it instead of a missing primary. It carries no HTTP status (STATUS_NONE), as the server answered 101, so connection health reports none, as for a missing durable-ack echo.CredentialRedaction, appended to theWebSocketUpgradeExceptionmessage and exposed asQwpAuthFailedException.getReason(). A refused owner (403) readsauth-rejected: ... [reason=owned_by refused: bob is not part of group team]instead of looking like a rejected credential.QwpWebSocketSender.connectWithCredentialSupplier(...)overload withownedBy; the previous master delegates to it withnull.Tests
QwpOwnedByTest: the header and its canonical encoding, including the ends of the unreserved ranges, the echo accepted, missing and mismatched, the header sent again on a reconnect, the reject reason with and without a body, its absence when the body is unusable (a Content-Length beyond the bytes received, malformed or not positive, another content type, a blank body), its sanitizing and length cap, both sender build paths (connect string and builder), a 403 refusal surfacing asQwpAuthFailedExceptionwith its reason, connect rounds that also meet a replica's 421 reporting the missing echo, also behind a 503, and the 403 refusal rather than a missing primary, and connection health on a missing echo.BackgroundDrainerEndToEndTest: an orphan drainer's upgrade names the owner too.WriteFailoverTest: a 503, a primary without durable ack and a replica, walked in that order, report the durable-ack mismatch.LineSenderBuilderWebSocketTest,WsSenderConfigHonoredTestandQwpQueryClientFromConfigTest: parsing, validation and the key-registry drift guard.